package com.abigdreamer.im.client.module.talk.file;

import java.awt.Color;

import javax.swing.Box;
import javax.swing.JComponent;
import javax.swing.JPanel;

import craky.componentc.JCScrollPane;

public class SendGetFilePanle extends JCScrollPane {

	private static final long serialVersionUID = 1L;

	private Box box;
	private JPanel panel;
	private JComponent parentComponent;

	public SendGetFilePanle() {
		super();
//		this.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	//	this.setBackground(Color.white);
		panel = new JPanel();
		panel.setBackground(Color.white);
		panel.setSize(241, 386);
		box = Box.createVerticalBox();// 竖立的放置
		panel.add(box);
		this.setViewportView(panel);
	}

	public void addFilePanle(SendGetFileNode fileProgressPanle) {
		box.add(fileProgressPanle);
		fileProgressPanle.setContainer(this);
		this.repaint();
	}

	public void removePanle(JPanel panel) {
		box.remove(panel);
		this.repaint();
		if (box.getComponents().length == 0) {
			this.getParentComponent().remove(this);
		}
	}

	public JComponent getParentComponent() {
		return parentComponent;
	}

	public void setParentComponent(JComponent parentComponent) {
		this.parentComponent = parentComponent;
	}
}
